package com.etc.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.etc.entity.OrderBean;
import com.etc.entity.OrderDetailBean;
import com.etc.entity.PageData;
import com.etc.service.OrderService;

@Controller
@RequestMapping(value="order")
public class OrderController {
	@Autowired
	private OrderService orderService;
	//分页
	@RequestMapping(value="list")
	public String orderList(@RequestParam(value="page",defaultValue="1") int page, @RequestParam(value="pageSize",defaultValue="6")int pageSize, @RequestParam(value="keywords",defaultValue="") String keywords,Model model) {
		PageData<OrderBean> pData=orderService.getOrByPage(page, pageSize, "%"+keywords+"%");
		model.addAttribute("pData", pData);
		model.addAttribute("keywords", keywords);
		 return "forward:/order.jsp";
	}
	@RequestMapping(value="getordetail/{orderId}",method=RequestMethod.GET)
	@ResponseBody
	public List<OrderDetailBean> orderTail(@PathVariable("orderId") int orderId){
		List<OrderDetailBean> list=orderService.doGetOrderDetal(orderId);
		return list;
		
	}
	
	
	
	

}
